


    ## WinBUGS code for a Varying-Intercept Model with Congress-Level Predictor  
    
    model {
    for (i in 1:N){
        Y[i] ~ dpois(mu.y[i])
        mu.y[i] <- (1 - u[i])*lambda[i]
        u[i] ~ dbern(p[i])

        logit(p[i]) <- min(999, max(-999, a[1] + a[2]*K1[i])) 
        
        log(lambda[i]) <- alpha[congress[i]] + 
                          zeta[congress[i]]*X1[i] + 
                          beta[1]*X2[i] + 
                          beta[2]*X3[i] +
                          beta[3]*X4[i] +
                          beta[4]*X5[i] +
                          beta[5]*X6[i] +
                          beta[6]*X7[i]
        }

        # priors
        for (i in 1:n.beta){
        beta[i] ~ dnorm(0, 0.1)
        }
        for (i in 1:n.a){
        a[i] ~ dnorm(0, 0.1)
        }

        for (j in 1:J){
        zeta[j] ~ dnorm(mu.zeta[j], tau.zeta)
        alpha[j] ~ dnorm(mu.alpha[j], tau.alpha)
        mu.zeta[j]  <- zeta.gamma[1] + 
                       zeta.gamma[2]*Z1[j] 
                                        
        mu.alpha[j] <- gamma[1] + 
                       gamma[2]*Z1[j]        
        }

        # priors
        for (i in 1:n.gamma){
        gamma[i] ~ dnorm(0, 0.1)
        }
        for (i in 1:n.zeta.gamma){
        zeta.gamma[i] ~ dnorm(0, 0.1)
        }        
        tau.alpha <- pow(sigma.alpha, -2)
        sigma.alpha ~ dunif(0, 100)
        tau.zeta <- pow(sigma.zeta, -2)
        sigma.zeta ~ dunif(0, 100)
    }

